package com.apotik.legenda.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name="apt_product")
public class Product implements Serializable {
	private static final long serialVersionUID = 3448025803207298346L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="product_id")
	private Long productId;
	
	@Column(name="product_code", length=50, unique=true, nullable=false)
	private String productCode;
	
	@Column(name="product_name", nullable=false)
	private String productName;
	
	@ManyToOne
	@JoinColumn(name="category_id", referencedColumnName = "category_id")
	private ProductCategory categoryId;
	
	@ManyToOne
	@JoinColumn(name="supplier_id", referencedColumnName = "supplier_id")
	private Supplier supplier;
	
	@Column(name="expire_date")
	@Temporal(TemporalType.DATE)
	private Date expireDate;
	
	@Column(name="product_unit", length=20, nullable=false)
	private String productUnit;
	
	@Column(name="available_stock", nullable=false)
	private Integer availableStock;
	
	@Column(name="price_buy", nullable=false)
	private BigDecimal priceBuy;
	
	@Column(name="price_sell", nullable=true)
	private BigDecimal priceSell;
	
	@Column(name="price_retail", nullable=true)
	private BigDecimal priceRetail;
	
	@Column(name="updated_price_date")
	@Temporal(TemporalType.TIMESTAMP)
	private Date updatedPriceDate;
	
	@ManyToOne
	@JoinColumn(name="created_by", referencedColumnName = "user_id", nullable = false)
	private User createdBy;
	
	@Column(name="created_date", nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdDate;
	
	@ManyToOne
	@JoinColumn(name="updated_by", referencedColumnName = "user_id")
	private User updatedBy;
	
	@Column(name="updated_date")
	@Temporal(TemporalType.TIMESTAMP)
	private Date updatedDate;
	
	@Column(name="is_active", nullable = false)
	private boolean isActive;

	
	public Long getProductId() {
		return productId;
	}

	public void setProductId(Long productId) {
		this.productId = productId;
	}

	public String getProductCode() {
		return productCode;
	}

	public void setProductCode(String productCode) {
		this.productCode = productCode;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public ProductCategory getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(ProductCategory categoryId) {
		this.categoryId = categoryId;
	}

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	public Date getExpireDate() {
		return expireDate;
	}

	public void setExpireDate(Date expireDate) {
		this.expireDate = expireDate;
	}
	
	public String getProductUnit() {
		return productUnit;
	}
	
	public void setProductUnit(String productUnit) {
		this.productUnit = productUnit;
	}

	public Integer getAvailableStock() {
		return availableStock;
	}

	public void setAvailableStock(Integer availableStock) {
		this.availableStock = availableStock;
	}

	public BigDecimal getPriceBuy() {
		return priceBuy;
	}

	public void setPriceBuy(BigDecimal priceBuy) {
		this.priceBuy = priceBuy;
	}

	public BigDecimal getPriceSell() {
		return priceSell;
	}

	public void setPriceSell(BigDecimal priceSell) {
		this.priceSell = priceSell;
	}
	
	public BigDecimal getPriceRetail() {
		return priceRetail;
	}
	
	public void setPriceRetail(BigDecimal priceRetail) {
		this.priceRetail = priceRetail;
	}

	public Date getUpdatedPriceDate() {
		return updatedPriceDate;
	}
	
	public void setUpdatedPriceDate(Date updatedPriceDate) {
		this.updatedPriceDate = updatedPriceDate;
	}

	public User getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(User createdBy) {
		this.createdBy = createdBy;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public User getUpdatedBy() {
		return updatedBy;
	}

	public void setUpdatedBy(User updatedBy) {
		this.updatedBy = updatedBy;
	}

	public Date getUpdatedDate() {
		return updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}

	public boolean isActive() {
		return isActive;
	}

	public void setActive(boolean isActive) {
		this.isActive = isActive;
	}
}
